From 48aa82fd37846f4281583badc0b90867ade0cc54 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 21 Sep 2014 09:27:08 -0700 Subject: [PATCH] Update to rust master --- Cargo.lock | 34 ++++++++++++------------ src/cargo/core/shell.rs | 22 +++++++-------- src/cargo/ops/cargo_generate_lockfile.rs | 4 +-- src/cargo/ops/cargo_rustc/context.rs | 19 ++++++------- src/cargo/ops/cargo_rustc/mod.rs | 13 ++++----- src/cargo/util/config.rs | 30 +++++++++++---------- src/cargo/util/toml.rs | 10 +++---- 7 files changed, 68 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index feb5c8008..f9b5b57a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,16 +3,16 @@ name = "cargo" version = "0.0.1-pre" dependencies = [ "curl 0.0.1 (git+https://github.com/alexcrichton/curl-rust?ref=bundle#720d87fa32c738c397252cf3c26d428bdca697d4)", - "docopt 0.6.3 (git+https://github.com/docopt/docopt.rs#ee3844098f213121ce7dfb32cdbf2512ecba7085)", - "docopt_macros 0.6.3 (git+https://github.com/docopt/docopt.rs#ee3844098f213121ce7dfb32cdbf2512ecba7085)", + "docopt 0.6.3 (git+https://github.com/docopt/docopt.rs#ca5a09aba10c5040220efe9d237a430f3b924736)", + "docopt_macros 0.6.3 (git+https://github.com/docopt/docopt.rs#ca5a09aba10c5040220efe9d237a430f3b924736)", "flate2 0.0.1 (git+https://github.com/alexcrichton/flate2-rs#a59b2a103642550bc1500c302c5031479ec7d9e1)", - "git2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#05276ae6dce9d3945104ffefb9e1496323351398)", + "git2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#08dc5e62bf11ff8957fcb98c0c3c57c764fc4879)", "glob 0.0.1 (git+https://github.com/rust-lang/glob#ce24c37f268c4a31238dbe3b8e9ff8fe5342f0be)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git#49061a2134d9112b8622d54587590f324b97cc98)", "semver 0.0.1 (git+https://github.com/rust-lang/semver#df163f7b22686493b037eee1f1f9d1a2742f9bbe)", "tar 0.0.1 (git+https://github.com/alexcrichton/tar-rs#b2391703d54afd20c999d5531c4ed46bcf366f23)", - "toml 0.1.0 (git+https://github.com/alexcrichton/toml-rs#5f5bd93203aa4c8e0602eb4def2d73d385cba74c)", - "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", + "toml 0.1.0 (git+https://github.com/alexcrichton/toml-rs#22ad6e7ea9f2a81aac3ba9e427dd8a1036453486)", + "url 0.1.0 (git+https://github.com/servo/rust-url#275c4a8e1926ab87247203817c9c812e9b83a49f)", ] [[package]] @@ -22,7 +22,7 @@ source = "git+https://github.com/alexcrichton/curl-rust?ref=bundle#720d87fa32c73 dependencies = [ "curl-sys 0.0.1 (git+https://github.com/alexcrichton/curl-rust?ref=bundle#720d87fa32c738c397252cf3c26d428bdca697d4)", "link-config 0.0.1 (git+https://github.com/alexcrichton/link-config#1d3cd271612036b47c015a55f33a97e1524569ae)", - "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", + "url 0.1.0 (git+https://github.com/servo/rust-url#275c4a8e1926ab87247203817c9c812e9b83a49f)", ] [[package]] @@ -33,20 +33,20 @@ source = "git+https://github.com/alexcrichton/curl-rust?ref=bundle#720d87fa32c73 [[package]] name = "docopt" version = "0.6.3" -source = "git+https://github.com/docopt/docopt.rs#ee3844098f213121ce7dfb32cdbf2512ecba7085" +source = "git+https://github.com/docopt/docopt.rs#ca5a09aba10c5040220efe9d237a430f3b924736" [[package]] name = "docopt_macros" version = "0.6.3" -source = "git+https://github.com/docopt/docopt.rs#ee3844098f213121ce7dfb32cdbf2512ecba7085" +source = "git+https://github.com/docopt/docopt.rs#ca5a09aba10c5040220efe9d237a430f3b924736" dependencies = [ - "docopt 0.6.3 (git+https://github.com/docopt/docopt.rs#ee3844098f213121ce7dfb32cdbf2512ecba7085)", + "docopt 0.6.3 (git+https://github.com/docopt/docopt.rs#ca5a09aba10c5040220efe9d237a430f3b924736)", ] [[package]] name = "encoding" version = "0.1.0" -source = "git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79" +source = "git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265" [[package]] name = "flate2" @@ -56,10 +56,10 @@ source = "git+https://github.com/alexcrichton/flate2-rs#a59b2a103642550bc1500c30 [[package]] name = "git2" version = "0.0.1" -source = "git+https://github.com/alexcrichton/git2-rs#05276ae6dce9d3945104ffefb9e1496323351398" +source = "git+https://github.com/alexcrichton/git2-rs#08dc5e62bf11ff8957fcb98c0c3c57c764fc4879" dependencies = [ - "libgit2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#05276ae6dce9d3945104ffefb9e1496323351398)", - "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", + "libgit2 0.0.1 (git+https://github.com/alexcrichton/git2-rs#08dc5e62bf11ff8957fcb98c0c3c57c764fc4879)", + "url 0.1.0 (git+https://github.com/servo/rust-url#275c4a8e1926ab87247203817c9c812e9b83a49f)", ] [[package]] @@ -75,7 +75,7 @@ source = "git+https://github.com/carllerche/hamcrest-rust.git#49061a2134d9112b86 [[package]] name = "libgit2" version = "0.0.1" -source = "git+https://github.com/alexcrichton/git2-rs#05276ae6dce9d3945104ffefb9e1496323351398" +source = "git+https://github.com/alexcrichton/git2-rs#08dc5e62bf11ff8957fcb98c0c3c57c764fc4879" dependencies = [ "libssh2-static-sys 0.0.1 (git+https://github.com/alexcrichton/libssh2-static-sys#6a5d3ad7b62db6ca0721c528402f4976a1876036)", "link-config 0.0.1 (git+https://github.com/alexcrichton/link-config#1d3cd271612036b47c015a55f33a97e1524569ae)", @@ -110,13 +110,13 @@ source = "git+https://github.com/alexcrichton/tar-rs#b2391703d54afd20c999d5531c4 [[package]] name = "toml" version = "0.1.0" -source = "git+https://github.com/alexcrichton/toml-rs#5f5bd93203aa4c8e0602eb4def2d73d385cba74c" +source = "git+https://github.com/alexcrichton/toml-rs#22ad6e7ea9f2a81aac3ba9e427dd8a1036453486" [[package]] name = "url" version = "0.1.0" -source = "git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379" +source = "git+https://github.com/servo/rust-url#275c4a8e1926ab87247203817c9c812e9b83a49f" dependencies = [ - "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79)", + "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)", ] diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 9c741e1ab..f1c71f47e 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -12,7 +12,7 @@ pub struct ShellConfig { enum AdequateTerminal<'a> { NoColor(Box), - Color(Box>+'a>) + Colored(Box>+'a>) } pub struct Shell<'a> { @@ -79,7 +79,7 @@ impl<'a> Shell<'a> { if config.tty && config.color { let term: Option>> = Terminal::new(out); term.map(|t| Shell { - terminal: Color(box t as Box>>), + terminal: Colored(box t as Box>>), config: config }).unwrap_or_else(|| { Shell { terminal: NoColor(box stderr() as Box), config: config } @@ -135,35 +135,35 @@ impl<'a> Terminal> for Shell<'a> { fn fg(&mut self, color: color::Color) -> IoResult { match self.terminal { - Color(ref mut c) => c.fg(color), + Colored(ref mut c) => c.fg(color), NoColor(_) => Ok(false) } } fn bg(&mut self, color: color::Color) -> IoResult { match self.terminal { - Color(ref mut c) => c.bg(color), + Colored(ref mut c) => c.bg(color), NoColor(_) => Ok(false) } } fn attr(&mut self, attr: Attr) -> IoResult { match self.terminal { - Color(ref mut c) => c.attr(attr), + Colored(ref mut c) => c.attr(attr), NoColor(_) => Ok(false) } } fn supports_attr(&self, attr: Attr) -> bool { match self.terminal { - Color(ref c) => c.supports_attr(attr), + Colored(ref c) => c.supports_attr(attr), NoColor(_) => false } } fn reset(&mut self) -> IoResult<()> { match self.terminal { - Color(ref mut c) => c.reset(), + Colored(ref mut c) => c.reset(), NoColor(_) => Ok(()) } } @@ -174,14 +174,14 @@ impl<'a> Terminal> for Shell<'a> { fn get_ref<'b>(&'b self) -> &'b Box { match self.terminal { - Color(ref c) => c.get_ref(), + Colored(ref c) => c.get_ref(), NoColor(ref w) => w } } fn get_mut<'b>(&'b mut self) -> &'b mut Box { match self.terminal { - Color(ref mut c) => c.get_mut(), + Colored(ref mut c) => c.get_mut(), NoColor(ref mut w) => w } } @@ -190,14 +190,14 @@ impl<'a> Terminal> for Shell<'a> { impl<'a> Writer for Shell<'a> { fn write(&mut self, buf: &[u8]) -> IoResult<()> { match self.terminal { - Color(ref mut c) => c.write(buf), + Colored(ref mut c) => c.write(buf), NoColor(ref mut n) => n.write(buf) } } fn flush(&mut self) -> IoResult<()> { match self.terminal { - Color(ref mut c) => c.flush(), + Colored(ref mut c) => c.flush(), NoColor(ref mut n) => n.flush() } } diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 3ec6560b7..44b281289 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -127,7 +127,7 @@ pub fn write_resolve(pkg: &Package, resolve: &Resolve) -> CargoResult<()> { Ok(()) } -fn emit_package(dep: &toml::Table, out: &mut String) { +fn emit_package(dep: &toml::TomlTable, out: &mut String) { out.push_str(format!("name = {}\n", lookup(dep, "name")).as_slice()); out.push_str(format!("version = {}\n", lookup(dep, "version")).as_slice()); @@ -151,6 +151,6 @@ fn emit_package(dep: &toml::Table, out: &mut String) { }); } -fn lookup<'a>(table: &'a toml::Table, key: &str) -> &'a toml::Value { +fn lookup<'a>(table: &'a toml::TomlTable, key: &str) -> &'a toml::Value { table.find(&key.to_string()).expect(format!("Didn't find {}", key).as_slice()) } diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 8307ed0cd..4b3531cd1 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -10,9 +10,9 @@ use super::layout::{Layout, LayoutProxy}; #[deriving(Show)] pub enum PlatformRequirement { - Target, - Plugin, - PluginAndTarget, + PlatformTarget, + PlatformPlugin, + PlatformPluginAndTarget, } pub struct Context<'a, 'b> { @@ -148,7 +148,8 @@ impl<'a, 'b> Context<'a, 'b> { let targets = pkg.get_targets().iter(); for target in targets.filter(|t| t.get_profile().is_compile()) { - self.build_requirements(pkg, target, Target, &mut HashSet::new()); + self.build_requirements(pkg, target, PlatformTarget, + &mut HashSet::new()); } self.compilation.extra_env.insert("NUM_JOBS".to_string(), @@ -165,7 +166,7 @@ impl<'a, 'b> Context<'a, 'b> { if !visiting.insert(pkg.get_package_id()) { return } let key = (pkg.get_package_id(), target.get_name()); - let req = if target.get_profile().is_plugin() {Plugin} else {req}; + let req = if target.get_profile().is_plugin() {PlatformPlugin} else {req}; self.requirements.insert_or_update_with(key, req, |_, v| { *v = v.combine(req); }); @@ -180,7 +181,7 @@ impl<'a, 'b> Context<'a, 'b> { pub fn get_requirement(&self, pkg: &'a Package, target: &'a Target) -> PlatformRequirement { self.requirements.find(&(pkg.get_package_id(), target.get_name())) - .map(|a| *a).unwrap_or(Target) + .map(|a| *a).unwrap_or(PlatformTarget) } /// Switch this context over to being the primary compilation unit, @@ -291,9 +292,9 @@ impl<'a, 'b> Context<'a, 'b> { impl PlatformRequirement { fn combine(self, other: PlatformRequirement) -> PlatformRequirement { match (self, other) { - (Target, Target) => Target, - (Plugin, Plugin) => Plugin, - _ => PluginAndTarget, + (PlatformTarget, PlatformTarget) => PlatformTarget, + (PlatformPlugin, PlatformPlugin) => PlatformPlugin, + _ => PlatformPluginAndTarget, } } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 40e58cdac..f79329639 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -11,7 +11,8 @@ use util::{Config, internal, ChainError, Fresh, profile}; use self::job::{Job, Work}; use self::job_queue::{JobQueue, StageStart, StageCustomBuild, StageLibraries}; use self::job_queue::{StageBinaries, StageEnd}; -use self::context::{Context, PlatformRequirement, Target, Plugin, PluginAndTarget}; +use self::context::{Context, PlatformRequirement, PlatformTarget}; +use self::context::{PlatformPlugin, PlatformPluginAndTarget}; pub use self::compilation::Compilation; @@ -275,12 +276,12 @@ fn prepare_rustc(package: &Package, target: &Target, crate_types: Vec<&str>, KindPlugin)); Ok(match req { - Target => vec![(target_cmd, KindTarget)], - Plugin => vec![(plugin_cmd, KindPlugin)], - PluginAndTarget if cx.config.target().is_none() => + PlatformTarget => vec![(target_cmd, KindTarget)], + PlatformPlugin => vec![(plugin_cmd, KindPlugin)], + PlatformPluginAndTarget if cx.config.target().is_none() => vec![(target_cmd, KindTarget)], - PluginAndTarget => vec![(target_cmd, KindTarget), - (plugin_cmd, KindPlugin)], + PlatformPluginAndTarget => vec![(target_cmd, KindTarget), + (plugin_cmd, KindPlugin)], }) } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index b780d9435..6c2918ade 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -1,6 +1,8 @@ use std::{fmt, os, result, mem}; use std::io::fs::{PathExtensions, File}; use std::collections::HashMap; +use std::string; + use serialize::{Encodable,Encoder}; use toml; use core::MultiShell; @@ -12,15 +14,15 @@ pub struct Config<'a> { home_path: Path, shell: &'a mut MultiShell<'a>, jobs: uint, - target: Option, - linker: Option, - ar: Option, + target: Option, + linker: Option, + ar: Option, } impl<'a> Config<'a> { pub fn new<'a>(shell: &'a mut MultiShell, jobs: Option, - target: Option) -> CargoResult> { + target: Option) -> CargoResult> { if jobs == Some(0) { return Err(human("jobs must be at least 1")) } @@ -71,9 +73,9 @@ impl<'a> Config<'a> { self.target.as_ref().map(|t| t.as_slice()) } - pub fn set_ar(&mut self, ar: String) { self.ar = Some(ar); } + pub fn set_ar(&mut self, ar: string::String) { self.ar = Some(ar); } - pub fn set_linker(&mut self, linker: String) { self.linker = Some(linker); } + pub fn set_linker(&mut self, linker: string::String) { self.linker = Some(linker); } pub fn linker(&self) -> Option<&str> { self.linker.as_ref().map(|t| t.as_slice()) @@ -91,9 +93,9 @@ pub enum Location { #[deriving(Eq,PartialEq,Clone,Decodable)] pub enum ConfigValue { - String(String, Path), - List(Vec<(String, Path)>), - Table(HashMap), + String(string::String, Path), + List(Vec<(string::String, Path)>), + Table(HashMap), Boolean(bool, Path), } @@ -122,7 +124,7 @@ impl> Encodable for ConfigValue { match *self { String(ref string, _) => string.encode(s), List(ref list) => { - let list: Vec<&String> = list.iter().map(|s| s.ref0()).collect(); + let list: Vec<&string::String> = list.iter().map(|s| s.ref0()).collect(); list.encode(s) } Table(ref table) => table.encode(s), @@ -189,7 +191,7 @@ impl ConfigValue { } } - pub fn table(&self) -> CargoResult<&HashMap> { + pub fn table(&self) -> CargoResult<&HashMap> { match *self { Table(ref table) => Ok(table), _ => Err(internal(format!("expected a table, but found a {}", @@ -197,7 +199,7 @@ impl ConfigValue { } } - pub fn list(&self) -> CargoResult<&[(String, Path)]> { + pub fn list(&self) -> CargoResult<&[(string::String, Path)]> { match *self { List(ref list) => Ok(list.as_slice()), _ => Err(internal(format!("expected a list, but found a {}", @@ -240,7 +242,7 @@ pub fn get_config(pwd: Path, key: &str) -> CargoResult { human(format!("`{}` not found in your configuration", key))) } -pub fn all_configs(pwd: Path) -> CargoResult> { +pub fn all_configs(pwd: Path) -> CargoResult> { let mut cfg = Table(HashMap::new()); try!(walk_tree(&pwd, |mut file| { @@ -325,7 +327,7 @@ pub fn set_config(cfg: &Config, loc: Location, key: &str, Global => cfg.home_path.join(".cargo").join("config"), Project => unimplemented!(), }; - let contents = File::open(&file).read_to_string().unwrap_or(String::new()); + let contents = File::open(&file).read_to_string().unwrap_or("".to_string()); let mut toml = try!(cargo_toml::parse(contents.as_slice(), &file)); toml.insert(key.to_string(), value.into_toml()); try!(File::create(&file).write(toml::Table(toml).to_string().as_bytes())); diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index fe5c6c04f..d0723b371 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -144,7 +144,7 @@ pub fn to_manifest(contents: &[u8], } } -pub fn parse(toml: &str, file: &Path) -> CargoResult { +pub fn parse(toml: &str, file: &Path) -> CargoResult { let mut parser = toml::Parser::new(toml.as_slice()); match parser.parse() { Some(toml) => return Ok(toml), @@ -538,7 +538,7 @@ fn process_dependencies<'a>(cx: &mut Context<'a>, dev: bool, struct TomlTarget { name: String, crate_type: Option>, - path: Option, + path: Option, test: Option, doctest: Option, bench: Option, @@ -548,7 +548,7 @@ struct TomlTarget { } #[deriving(Decodable, Clone)] -enum TomlPath { +enum TomlPathValue { TomlString(String), TomlPath(Path), } @@ -569,7 +569,7 @@ impl TomlTarget { } } -impl TomlPath { +impl TomlPathValue { fn to_path(&self) -> Path { match *self { TomlString(ref s) => Path::new(s.as_slice()), @@ -578,7 +578,7 @@ impl TomlPath { } } -impl fmt::Show for TomlPath { +impl fmt::Show for TomlPathValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { TomlString(ref s) => s.fmt(f), -- 2.30.2